<template>
<div class="menuBigBox g-clearfix">
  <swiper :options="swiperOption" v-if="showSwiper">
    <swiper-slide v-for="(page, index) in pages" :key="index">
      <div class="menuBox" v-for="item in page" :key="item.id">
        <div class="imgBox">
          <img :src="item.imgUrl" alt="">
        </div>
        <div class="describe g-overflow-hidden">{{item.desc}}</div>
      </div>
    </swiper-slide>
    <div class="swiper-pagination"  slot="pagination"></div>
  </swiper>
</div>
</template>
<script type='text/babel'>
export default {
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
    }
  },
  created () {
  },
  computed: {
    showSwiper () {
      return this.list.length
    },
    pages () {
      const pages = []
      this.list.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  },
  methods: {},
  components: {}
}
</script>
<style>
  .swiper-pagination-bullet-active{
    background: red;
  }
</style>
<style scoped lang="scss" rel="stylesheet/scss">
  @import "../../../assets/styles/variable";
  .menuBigBox .swiper-container{
    width:100%;
    padding: 5px 0 20px 0;
  }
  .menuBigBox{
    background: #fff;
    .menuBox{
      width:25%;
      height:80px;
      float: left;
      padding: 5px 0;
      box-sizing: border-box;
      .imgBox{
        text-align: center;
        img{
          width:50px;
          height:50px;
        }
      }
      .describe{
        height:20px;
        line-height:20px;
        font-size: 12px;
        text-align: center;
      }
    }
  }
</style>
